import * as actionTypes from './constant';
import { Map } from 'immutable';

const defaultState = Map({
  categoryList: [],
  departmentList: [],
  goodsList: [],
  rolesList: [],
  usersList: [],
  dashboardList: [],
});

function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_CATEGORY:
      return state.set('categoryList', action.categoryList);
    case actionTypes.CHANGE_DEPARTMENT:
      return state.set('departmentList', action.departmentList);
    case actionTypes.CHANGE_GOODS:
      return state.set('goodsList', action.goodsList);
    case actionTypes.CHANGE_ROLES:
      return state.set('rolesList', action.rolesList);
    case actionTypes.CHANGE_USERS:
      return state.set('usersList', action.usersList);
    case actionTypes.CHANGE_DASHBOARD:
      return state.set('dashboardList', action.dashboardList);
    default:
      return state;
  }
}

export default reducer;
